package com.lingxu.module.redList.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingxu.base.common.api.vo.Result;
import com.lingxu.module.redList.entity.RedListApply;
import com.lingxu.module.redList.mapper.RedListApplyMapper;
import com.lingxu.module.redList.service.RedListApplyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Title: RedListApplyServiceImpl
 * @Package: com.lingxu.module.redList.service.impl
 * @Author: ysj闫世杰
 * @Email: 1105324813@qq.com
 * @Date: Created in 2023/6/19 17:10
 * @Description:
 * @Version: 1.0.0
 */
@Service
public class RedListApplyServiceImpl extends ServiceImpl<RedListApplyMapper, RedListApply>
        implements RedListApplyService {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private RedListApplyMapper redListApplyMapper;

    /**
     * @Author ysj闫世杰
     * @Description 查询申请列表
     * @Date 2023/6/20 9:21
     * @Param: limit
     * @Param: page
     * @return com.lingxu.base.common.api.vo.Result
     **/
    @Override
    public Result findRedListApplyData(Integer limit, Integer page,String status,String cityCode) {
        try {
            Page<RedListApply> iPage = new Page<>(page,limit);
            IPage<RedListApply> pageList = redListApplyMapper.findRedListApplyData(iPage,status,cityCode);
            return Result.ok(pageList,"查询成功");
        }catch (Exception e){
            logger.error("数据查询异常",e);
            return Result.error("查询异常");
        }
    }

    /**
     * @Author ysj闫世杰
     * @Description 查询唯一性·
     * @Date 2023/6/28 9:25
     * @Param: recordId
     * @return int
     **/
    @Override
    public int findExist(String recordId) {
        try {
            return redListApplyMapper.findExist(recordId);
        }catch (Exception e){
            logger.error("操作异常",e);
            return 0;
        }
    }

    //唯一性校验
    @Override
    public int findExistByIdCard(String idcard) {
        return redListApplyMapper.findExistByIdCard(idcard);
    }
}
